#include <bits/stdc++.h>
using namespace std;
//#define int long long
int read () {
    int s=0,f=1;
    char t=getchar();
    while ((t>'9'||t<'0')&&t!='-') t=getchar();
    if (t=='-') {
        f=-1;
        t=getchar();
    }
    while (t<='9'&&t>='0') {
        s=s*10+(t-'0');
        t=getchar();
    }
    return s*f;
}
int n,ans=INT_MAX/2,cnt;
int r[1000001];
int pl[1000001],h[1001],p[1001];
int check () {
    for (int i=1;i<=n;i++) {
        p[i]=1;
    }
    for (int i=1;i<=n;i++) {
        if (pl[i]!=0&&r[pl[i]]<r[i]) p[i]=0; 
    }
    int cnt=0;
    for (int i=1;i<=n;i++) {
        if (p[i]==1) {
            cnt++;
        }  
    }
    int f=1;
    for (int i=1;i<=n;i++) {
        if (p[i]==1&&pl[i]==0) {
            f=-1;
            break;
        }  
    }
    if (f==1) return cnt;
    return INT_MAX/2;
}
void work (int dep) {
    if (dep>n) {
        ans=min(ans,check());
        cnt++;
        return ;
    }
    /*pl[dep]=0;
    work(dep+1);*/
    for (int i=1;i<=n;i++) {
        if (h[i]==0) {
            pl[dep]=i;
            h[i]=1;
            work(dep+1);
            h[i]=0;
        }
    }
}
signed main () {
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    n=read();
    for (int i=1;i<=n;i++) {
        r[i]=read();
    }
    if (n<=10) {
        work(1);
        cout<<ans;
    }
    else {
        int res=0;
        for (int i=1;i<=n;i++) {
            if (r[i]==2) res++;
        }
        cout<<res;
    }
    return 0;
}